{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a478994",
   "metadata": {},
   "outputs": [],
   "source": [
    "# jupyter notebook网站出问题，先查看cmd有没有问题"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "328bbdaa",
   "metadata": {},
   "source": [
    "### list练习以及字典"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1465d2c2",
   "metadata": {},
   "source": [
    "#### 上周回顾"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d191e048",
   "metadata": {},
   "source": [
    "> * list一般方法及函数 所有的使用场景案例，方法如：\n",
    ">> 1. append()\n",
    ">> 2.pop(index)\\remove(values)\n",
    ">> 3.count()\n",
    ">> 4.index()\n",
    ">> 5.extend()\n",
    ">> 6.sort()\n",
    "> * list高级方法，如：\n",
    ">> 1.copy()  复制 不等于 赋值，复制可等价于切片[:]\n",
    ">> 2.enu\n",
    "> * 课本练习 Don't panic ==>on tap,其中知识点：\n",
    ">> 1.list的一些方法实现\n",
    ">> 2.list切片实现\n",
    ">> 3.str =>list 的方法 list(str)\n",
    ">> 4.list => str 的方法 ’’.join(list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "74742607",
   "metadata": {},
   "source": [
    "### 本周内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02572afb",
   "metadata": {},
   "source": [
    "#### 课本练习1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e8579300",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "vowels = ['a','e','i','o','u'] # 这是元音\n",
    "word = \"Milliways\" # 这是文本（str）\n",
    "# 需求：word中出现的vowels打印出来\n",
    "for letter in word:   # 循环的第一个位置的元素（for 后面的元素）请注意名字不要和已经定义过的变量重复；letter 可以随便命名，不会影响结果(通常为i)\n",
    "                  # 第二个元素（in后面的元素）决定你要循环的内容\n",
    "  #  print(\"当前字母为：\",i)  # 循环的列表，每个元素单独在一行\n",
    "  if letter in vowels:\n",
    "    print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a5c54c79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['i', 'a']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# append（）经常用来新建列表\n",
    "found = []\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        if letter not in found:\n",
    "            found.append(letter)\n",
    "found"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a21bc6b0",
   "metadata": {},
   "source": [
    "# 数据结构练习1\n",
    "\n",
    "* 购物车程序项目：\n",
    "* 要求：\n",
    "1. 运行程序后，让用户输入支付宝余额，然后打印我们商品列表给用户。\n",
    "2. 让用户输入商品编号进行商品的购买。\n",
    "3. 用户选择商品后，检查用户的余额是否够，若够则直接扣款，不够则提醒用户。\n",
    "4. 用户可以随时退出购买，推出时打印用户已购买的商品和支付宝余额。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a277eb33",
   "metadata": {},
   "outputs": [],
   "source": [
    "goods_list =[\"可乐，5r\",\"面包，10r\",\"矿泉水，2r\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3c944848",
   "metadata": {},
   "outputs": [],
   "source": [
    "user_shopping_list = [\"nana\",\"coco\",\"huihui\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "86986a43",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入支付宝余额: 12\n"
     ]
    }
   ],
   "source": [
    "money_balance = input(\"请输入支付宝余额: \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f39f2742",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'num' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-8-de2e12e0e411>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mmoney_balance\u001b[0m \u001b[1;33m>\u001b[0m \u001b[0mnum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m15\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnext\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'num' is not defined"
     ]
    }
   ],
   "source": [
    "if money_balance > num(15):\n",
    "    print(next)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "763fe407",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
